mui.init({
	swipeBack: true, //启用右滑关闭功能
});
mui.plusReady(function() {
	var wv = plus.webview.currentWebview('../loginregistration/login.html');
	// 关闭侧滑返回功能
	wv.setStyle({
		'popGesture': 'none'
	});
})
var vm = new Vue({
	el: '.mui-content',
	data: {
		list: [],
		books: [],
		imgurl: '',
		notice: []
	},
	updated: function() {
		var lunbo = mui('#slider');
		lunbo.slider({
			interval: 8000,
		});
		$(".classbooks").on("tap", function() {
			common.open("../bookdetails/details.html", "", $(this).attr("bookuid"))
		})

		var oUl = document.getElementsByTagName('ul')[0];
		//复制两份ul里面的内容到ul中，为的是实现无缝
		oUl.innerHTML = oUl.innerHTML + oUl.innerHTML;
		//计算新的ul的长度
		var temp = 0
		$.each($(".marquee_li"), function() {
			temp += $(this).width()
		});
		$(".marquee_ul").width(temp)
		//设置速度
		var speed = -0.6;

		function move() {
			//向左移动
			if(oUl.offsetLeft < -oUl.offsetWidth / 2) {
				oUl.style.left = '0';
			}
			oUl.style.left = oUl.offsetLeft + speed + 'px';
		}
		var timer = setInterval(move, 80);

	}
});

mui('.mui-scroll-wrapper').scroll({
	indicators: false, //是否显示滚动条
	bounce: false
});

common.ajax("banner/2", {
	uid: common.uid,
	token: common.token

}, function(data) {

	if(data.code == 200) {
		vm.list = data.data
		vm.imgurl = data.data[0].url
	} else {
		mui.toast(data.message)
	}
})

common.ajax("student/index/indexRecommend", {
	uid: common.uid,
	token: common.token,
	readState: 1,
	//  grade:'一年级',
	//  categoryUid:"fc4eceb634a54eada872c51b9ed0d850",
	page: 1,
	pageSize: 4
}, function(data) {
	for(var i = 0; i < data.data.length; i++) {
		vm.books.push(data.data[i])
	}
	vm.$nextTick(function() {
		$(".booksimg").height($(".booksimg").find("img").width() * (16 / 12))
	})
}, 'get')

// 扩展API加载完毕后调用onPlusReady回调函数 
var lunbo = mui('#slider');
lunbo.slider({
	interval: 8000,
});

common.ajax("student/index/notice", {
	uid: common.uid,
	token: common.token
}, function(data) {
	if(data.code == 200) {

		//		for(var i=0; i<data.data.length; i++){
		vm.notice = data.data
		//		}

	} else {
		mui.toast(data.message)
	}
}, "get")

$(".read").on("tap", function() {
	location.reload();
})

$(".readsquare").on("tap", function() {
	common.open("../langdu/emptyreading.html")
})

common.clsopen()

$(document).on("tap", ".more", function() {
	var indexId = plus.webview.getWebviewById("index.html");
	mui.fire(indexId, "gohome");
})